/** @author dongls */
(function(){
  if(!window.Promise || Object.prototype.toString.call(Promise.resolve()) != '[object Promise]'){
    document.write('<script src="/resource/polyfill/es6-promise.min.js"></script>')
  }

  if(window.Promise && typeof window.Promise.prototype.finally != 'function'){
    Promise.prototype.finally = function (callback) {
      var promise = this;
      var constructor = promise.constructor;

      return promise.then(function (value) {
        return constructor.resolve(callback()).then(function () {
          return value;
        });
      }, function (reason) {
        return constructor.resolve(callback()).then(function () {
          throw reason;
        });
      });
    };
  }
})();